package net.uhuijia.user.useraddress.controller;

import net.uhuijia.user.useraddress.persistence.model.UserAddress;
import net.uhuijia.user.useraddress.persistence.model.UserAddressExample;
import net.uhuijia.user.usermall.persistence.model.UserMall;
import net.uhuijia.vo.ResultMapVo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import net.uhuijia.appbase.controller.BaseController;
import net.uhuijia.user.useraddress.service.UserAddressService;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping(value="/useraddress")
public class UserAddressController
     extends BaseController<UserAddressService,UserAddress,UserAddressExample>{
    @Autowired
    private UserAddressService userAddressService;

    @RequestMapping(value="addAddress")
    @ResponseBody
    public ResultMapVo addAddress(String receiveName,String receivePhone,String provinceId,String cityId,String regionId,String detailaAddress,String isDefault){
        if(!StringUtils.isNoneBlank(receiveName,receivePhone,provinceId,cityId,regionId))
            throw new IllegalArgumentException();
        UserMall userMall = this.getUserMallByTokenAndDevice();
        this.userAddressService.addAddress(userMall,receiveName,receivePhone,provinceId,cityId,regionId,detailaAddress,isDefault);
        return ResultMapVo.ok();
    }
    @RequestMapping(value="addressList")
    @ResponseBody
    public ResultMapVo addressList(HttpServletRequest request){


        return ResultMapVo.ok();
    }

}